package io.comparison.controller;


import io.comparison.pojo.DataSourceVO;
import io.comparison.service.ComparisonService;
import io.comparison.utils.PageUtils;
import io.comparison.utils.Query;
import io.comparison.utils.R;
import io.comparison.utils.ScrewUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/")
public class ComparisonController {

    @Autowired
    private ComparisonService comparisonService;

    /**
     * 相同数据表列表
     */
    @ResponseBody
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok().put("data", comparisonService.queryList(params));
    }

    /**
     * 测试库独有数据表列表
     */
    @ResponseBody
    @RequestMapping("/list/test")
    public R listTestTable(@RequestParam Map<String, Object> params) {
        return R.ok().put("data", comparisonService.queryTestList(params));
    }

    /**
     * 测试库独有数据表列表
     */
    @ResponseBody
    @RequestMapping("/list/prod")
    public R listProdTable(@RequestParam Map<String, Object> params) {
        return R.ok().put("data", comparisonService.queryProdList(params));
    }

    /**
     * 获取指定表的正式环境，测试环境字段
     */
    @ResponseBody
    @RequestMapping("/getTable")
    public R getTable(@RequestParam Map<String, Object> params) {
        return R.ok().put("data", comparisonService.getTable(params));
    }

    @PostMapping("/getDoc")
    public void getHtml(@RequestBody DataSourceVO dataSourceVO){
        System.out.println(dataSourceVO);
        ScrewUtils.getHtml(dataSourceVO);
//        return R.ok("已生成到项目同级目录！");
    }

}
